<template>
	<view class="container">
		<BhTitle titleText="求租详情"></BhTitle>
		<view class="post-detail">
			<view style="position: absolute;left: 0px;width: 6px;height: 18px;background: #F8D247;">

			</view>

			<view v-if="postDto.metricRecordDtoMap.collect != 1 && !isMyPost(postDto)" @click="confirmCollect"
				class="bh-row bh-justify-space-between bh-align-center save">
				<view class="">收藏</view>
				<image class="save-image" src="../images/detail/collect.svg"></image>
			</view>
			<view v-if="postDto.metricRecordDtoMap.collect == 1 && !isMyPost(postDto)" @click="cancelCollect"
				class="bh-row bh-justify-space-between bh-align-center save">
				<view class="">收藏</view>
				<image class="save-image" src="../images/detail/collected.svg"></image>
			</view>

			<!-- <view v-if="postDto.metricRecordDtoMap.collect != 1 && !isMyPost(postDto)" @click="confirmCollect" class="save">
				收藏
				<image class="save-image" src="../images/detail/collect.svg"></image>
			</view>

			<view v-if="postDto.metricRecordDtoMap.collect == 1 && !isMyPost(postDto)" @click="cancelCollect" class="save">
				收藏
				<image class="save-image" src="../images/detail/collected.svg"></image>
			</view> -->

			<!-- <view v-if="postDto.metricRecordDtoMap.collect != 1" @click="confirmCollect" class="detail-collect-wrap bh-row bh-justify-space-between">
				<view class="detail-collect-title">收藏</view>
				<image class="detail-collect" src="../images/detail/collect.svg" mode="scaleToFill" />
			</view>
			<view v-if="postDto.metricRecordDtoMap.collect == 1" @click="cancelCollect" class="detail-collect-wrap bh-row bh-justify-space-between">
				<view class="detail-collect-title">收藏</view>
				<image class="detail-collect" src="../images/detail/collected.svg" mode="scaleToFill" />
			</view> -->
			<view class="detail-title">
				求租{{ postDto.area }}{{ postDto.street }}的店铺
			</view>
			<view class="detail-times">
				<view>{{ postDto.createTimeDesc }}&nbsp;|&nbsp;</view>
				<view>{{ postDto.viewNumber }}次浏览</view>
			</view>
			<view style="border-bottom: 0.5px solid #EEEEEE;margin-top: 24rpx;"></view>

			<view v-for="(item, index) in getItemInfo" :key="index">
				<view class="info-wrap">
					<view class="info-title">{{ item.title }}:</view>
					<view class="info-content">{{ item.content }}</view>
				</view>
			</view>
		</view>
		<view v-if="!isMyPost(postDto) && !fromMessagePage" class="share">
			<view class="share-info">
				<view class="share-info-title1">
					向TA推荐我的店铺
				</view>
				<view class="share-info-title2">
					对方收到点击即可打开我的店铺
				</view>
			</view>
			<view @click="toRecommend" class="share-btn">
				立即推荐
			</view>
		</view>

		<view class="footer">
			<!-- <view class="avatar"></view> -->
			<image class="avatar" style="display:block" :src="postDto.userDto.avatarUrl" mode="scaleToFill" />
			<view class="nickname-wrap">
				<view class="nickname">{{ postDto.userDto.nickName }}
				
				</view>
				<!-- <view v-if="sessionDto.postNumber > 0" class="nickname-label">
					<image class="label-icon" src="../images/detail/renzheng.svg" mode="scaleToFill" />
					<view class="label-title">店主认证</view>
				</view> -->
			</view>
			<view v-if="!isMyPost(postDto) && !fromMessagePage" class="bh-row bh-justify-end bh-flex-1">
				<view class="comment" @click="toComment">在线聊</view>
				<view @click="toMakePhone(postDto)" class="contact">联系他</view>
			</view>
			<!-- <image
          src="../images/detail/location.png"
          mode="scaleToFill"
        /> -->

		</view>
		<show-add-comment-sheet v-if="showAddComment" ref="textarea1" :show="showAddComment"
			@close="() => { this.showAddComment = false }" :init-value="commentContent" @confirm="addComment"
			@change="changeComment"></show-add-comment-sheet>
		<show-recommend-post-sheet :itemList="myPostListOfSell" @close="showRecommendPost = false"
			:show="showRecommendPost" @changeItem="changeItem"
			@confirm="addCommentRecommend"></show-recommend-post-sheet>
		<!-- <showCustomModal></showCustomModal> -->
		<showCustomTips></showCustomTips>
	</view>
</template>

<script>
	import {
		Api
	} from '../../api/api';
	import {
		Dict
	} from '../../components/custom_views/dict';
	import BhTitle from '../../components/custom_views/bh-title.vue';
	import showAddCommentSheet from '@/PostPage/custom_views/show-add-comment-sheet.vue';
	import check_utils from '../../components/custom_views/check_utils';
	import showRecommendPostSheet from '../../components/custom_views/show-recommend-post-sheet.vue';
	import {
		CustomDict
	} from '../../components/custom_views/custom_dict';
	import {
		commonMixin
	} from '../../components/custom_views/mixin';
	import {
		CustomTips
	} from '../../components/custom_views/custom_tips';
	import {
		PostUtils
	} from '@/components/post_item/post_add_sell_dto';
	import {
		BackendApi
	} from '../../api/backend_api';
import { CustomDate } from '../../components/custom_views/custom_date';
import showCustomTips from '../../components/custom_views/show-custom-tips.vue'

	export default {
		components: {
			BhTitle,
			showAddCommentSheet,
			showRecommendPostSheet,
			showCustomTips
		},
		mixins: [
			commonMixin
		],
		data() {
			return {
				sessionDto: this.$store.state.sessionDto,
				postDto: {},
				fromMessagePage: false,
				showAddComment: false,
				commentContent: '',
				itemList: [{
						checked: false,
						id: 123,
						name: 'sdfsdf'
					},
					{
						checked: false,
						id: 1234,
						name: '是对方说'
					}

				],
				showRecommendPost: false,
				myPostList: [],
				// myPostListOfSell: this.$store.getters.myPostListOfSell,

				itemInfos: [{
						title: '面积要求',
						content: '10-20㎡'
					},
					{
						title: '租金范围',
						content: '1k-2k'
					},
					{
						title: '区域要求',
						content: '安贞'
					},
					{
						title: '计划经营',
						content: '酒店餐饮'
					},
					{
						title: '商铺类型',
						content: '酒店'
					},
					{
						title: '是否接受转让费',
						content: '是'
					}
				],
			}
		},
		computed: {
			// isMember(){
			// 		  return this.$store.state.sessionDto.userDto.memberLevel == 1801 && 
			// 		  CustomDate.calSecondsFromDate(this.$store.state.sessionDto.userDto.memberExpireDate) < 0
			// },
			myPostListOfSell() {
				console.log('我的发帖列表', this.myPostList)
				return this.myPostList.filter(post =>
					post.postType == Dict.PostMainTypeEnum.Shop.childs.ShopSell.value &&
					post.postStatus == CustomDict.PostStatusEnum.Agree.value)
			},
			getAcreage() {
				if (this.postDto.upperAcreage >= 10000) {
					return '不限'
				} else {
					return this.postDto.lowerAcreage + '-' + this.postDto.upperAcreage
				}
			},
			getItemInfo() {
				let acreateInfo = ''
				if (this.postDto.upperAcreage >= 10000) {
					acreateInfo = '不限'
				} else {
					acreateInfo = this.postDto.lowerAcreage + '-' + this.postDto.upperAcreage
				}

				let needTransFee = '是'
				if (this.postDto.transferFeeDiscuss == 0) {
					if (this.postDto.transferFee > 0) {
						needTransFee = '是'
					} else {
						needTransFee = '否'
					}
				}

				if (this.postDto.upperRent >= 10000) {
					acreateInfo = '不限'
				} else {
					acreateInfo = this.postDto.lowerAcreage + '-' + this.postDto.upperAcreage
				}
				return [{
						title: '面积要求',
						content: this.buyAcreage(this.postDto)
					},
					{
						title: '租金范围',
						content: this.buyRent(this.postDto)
					},
					{
						title: '区域要求',
						content: this.postDto.area
					},
					// {
					// 	title: '计划经营',
					// 	content: CustomDict.getDictName(this.postDto.industryId, Dict.IndustryTypeEnum)
					// },
					{
						title: '商铺类型',
						content: CustomDict.getDictName(this.postDto.industryId, Dict.IndustryTypeEnum)
					},
					{
						title: '是否接受转让费',
						content: needTransFee
					}
				]
			},
		},
		methods: {
			toRecommend() {
				let that = this
				if (this.$store.state.sessionDto.postNumber <= 0) {
					this.showCustomModal({
						content: CustomTips.tipsNoPostAddSell,
						confirmText: '去发布',
						success(res) {
							if (res.confirm) {
								that.hideCustomModal()
								uni.navigateTo({
									url: '/PostPage/post_add_sell/post_add_sell'
								})
							} else {

							}
						}
					})
				} else {
					this.showRecommendPost = true
				}


			},
			changeItem(index) {

			},
			toComment() {
				let that = this
				if (!PostUtils.canCommentOrContact(this.postDto)) {
					return
				}
				if (this.$store.state.sessionDto.postNumber <= 0) {
					this.showCustomModal({
						content: CustomTips.tipsCommentBeforePostSell,
						confirmText: '去发布',
						success(res) {
							if (res.confirm) {
								that.hideCustomModal()
								uni.navigateTo({
									url: '/PostPage/post_add_sell/post_add_sell'
								})
							} else {

							}
						}
					})
				} else {
					
					
					Api.CommentApi.imAddCount(that,(res) => {
						let remainCount = CustomDict.ConstantVals.NonMember.CountOfChat - (res.data ? res.data : 0)
						if(that.isMember()){
							that.startConversation()
						}else if(res.code == 200){
							let aaa = res.data && res.data >= CustomDict.ConstantVals.NonMember.CountOfChat
							console.log('是否会员',aaa)
							if(res.data && res.data >= CustomDict.ConstantVals.NonMember.CountOfChat){
								that.showCustomTips({
								  title: '温馨提示',
								  content: CustomDict.ConstantVals.NonMember.TipOfChat,
								  confirmText: '注册会员',
								  confirmColor: '',
								  cancelText: '取消',
								  success(res) {
								    if (res.confirm) {
								      uni.redirectTo({
								        url: '/MemberPage/member_index/member_index'
								      })
								    }else {
										
									}
								  }
								})
							}else{
								that.showCustomTips({
								  title: '温馨提示',
								  content: CustomDict.ConstantVals.NonMember.TipOfChatFun(res.data),
								  confirmText: '确定',
								  confirmColor: '',
								  cancelText: '取消',
								  
								  success(res) {
								    if (res.confirm) {
								      if (that.postDto.userDto.imUserId) {
										that.startConversation()
								      
								      }
								    }else {
										
									}
								  }
								})
							}
						}
					}, false)
					

					// this.showAddComment = true
					// this.commentContent = ''
					// this.$nextTick(() => {
					// 	this.$refs.textarea1.focusInput();
					// });
				}

			},
			addCommentRecommend(postIndex) {
				let that = this
				console.log('推荐的发帖列表索引', postIndex)
				this.showRecommendPost = false
				let recommendRecordId = this.myPostListOfSell[postIndex].id
				
				
				Api.CommentApi.imAddCount(that,(res) => {
					let remainCount = CustomDict.ConstantVals.NonMember.CountOfChat - (res.data ? res.data : 0)
					if(that.isMember()){
						that.startConversation()
					}else if(res.code == 200){
						if(res.data && res.data >= CustomDict.ConstantVals.NonMember.CountOfChat){
							that.showCustomTips({
							  title: '温馨提示',
							  content: CustomDict.ConstantVals.NonMember.TipOfChat,
							  confirmText: '注册会员',
							  confirmColor: '',
							  cancelText: '取消',
							  success(res) {
							    if (res.confirm) {
							      uni.redirectTo({
							        url: '/MemberPage/member_index/member_index'
							      })
							    }else {
									
								}
							  }
							})
						}else{
							that.showCustomTips({
							  title: '温馨提示',
							  content: CustomDict.ConstantVals.NonMember.TipOfChatFun(res.data),
							  confirmText: '确定',
							  confirmColor: '',
							  cancelText: '取消',
							  
							  success(res) {
							    if (res.confirm) {
							      if (that.postDto.userDto.imUserId) {
									  that.startConversation()
							      
							      }
							    }else {
									
								}
							  }
							})
						}
					}
				}, false)

				// Api.CustRequestSubscribeMessage(() => {
				// 	// Api.CommentApi.addNew(
				// 	// 	that,
				// 	// 	that.postDto.id,
				// 	// 	that.postDto.userId,
				// 	// 	'我这里有个商铺很符合你的要求，快来看看吧',
				// 	// 	0,
				// 	// 	recommendRecordId,
				// 	// 	(res) => {
				// 	// 		if (res.code == 200) {
				// 	// 			check_utils.showCustToast('推荐成功')
				// 	// 		} else {
				// 	// 			check_utils.showCustToast(res.msg)
				// 	// 		}
				// 	// 	},
				// 	// 	true
				// 	// )
				// }, () => {
				// 	// Api.CommentApi.addNew(
				// 	// 	that,
				// 	// 	that.postDto.id,
				// 	// 	that.postDto.userId,
				// 	// 	'我这里有个商铺很符合你的要求，快来看看吧',
				// 	// 	0,
				// 	// 	recommendRecordId,
				// 	// 	(res) => {
				// 	// 		if (res.code == 200) {
				// 	// 			check_utils.showCustToast('推荐成功')
				// 	// 		} else {
				// 	// 			check_utils.showCustToast(res.msg)
				// 	// 		}
				// 	// 	},
				// 	// 	true
				// 	// )
				// })

			},
			startConversation(){
				let that = this
				// 记录发起聊天记录到后台
				Api.CustRequestSubscribeMessage(
					() => {
						Api.CommentApi.addImNew(
							that,
							that.postDto.id,
							that.postDto.userId,
							'您有新的未读消息',
							0,
							0,
							(res) => {
								// if (res.code == 200) {
								// 	check_utils.showCustToast('留言成功')
								// 	that.commentContent = ''
								// } else {
								// 	check_utils.showCustToast(res.msg)
								// }
							},
							false
						)
						
						if (that.postDto.userDto.imUserId) {
							// 切换会话进入聊天
							const conversationID = `C2C${that.postDto.userDto.imUserId}`;
							// // #ifdef APP-PLUS || H5
							TUIConversationService.switchConversation(conversationID);
							// // #endif
							uni.navigateTo({
								url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}`,
							});
						}
												      
					},
					() => {
												      
						Api.CommentApi.addImNew(
							that,
							that.postDto.id,
							that.postDto.userId,
							'您有新的未读消息',
							0,
							0,
							(res) => {
								// if (res.code == 200) {
								// 	check_utils.showCustToast('留言成功')
								// 	that.commentContent = ''
								// } else {
								// 	check_utils.showCustToast(res.msg)
								// }
							},
							false
						)
						
						if (that.postDto.userDto.imUserId) {
							// 切换会话进入聊天
							const conversationID = `C2C${that.postDto.userDto.imUserId}`;
							// // #ifdef APP-PLUS || H5
							TUIConversationService.switchConversation(conversationID);
							// // #endif
							uni.navigateTo({
								url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}`,
							});
						}
					}
				)
			},
			toMakePhone(item) {
				let that = this
				if (!PostUtils.canCommentOrContact(item)) {
					return
				}
				// if(item.userDto.userId < 10000000000){
				// 	this.showCustomModal({
				// 		content: CustomTips.tipsNoContactPhone,
				// 		cancelColor: '#666666',
				// 		cancelText: '',
				// 		confirmColor: 'rgba(0, 0, 0, 0.85)',
				// 		confirmText: '确定',
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('点击了确定', res)
				// 				that.hideCustomModal()
				// 			} else if (res.cancel) {
				// 				console.log('用户取消注销');
				// 			}
				// 		}
				// 	})
				// 	return
				// }
				
				
				
				
				if (!(this.$store.state.sessionDto.postNumber > 0)) {
					console.log('用户发布的转铺数', this.$store.state.sessionDto.postNumber)
					this.showCustomModal({
						content: CustomTips.tipsCommentBeforePostSell,
						cancelColor: '#666666',
						cancelText: '我知道啦',
						confirmColor: 'rgba(0, 0, 0, 0.85)',
						confirmText: '去发布',
						success: function(res) {
							if (res.confirm) {
								console.log('点击了确定', res)
								uni.redirectTo({
									url: '/PostPage/post_add_sell/post_add_sell'
								})
							} else if (res.cancel) {
								console.log('用户取消注销');
							}
						}
					})
					return
				} else {
					
					// 获取打电话次数
					Api.CommentApi.phoneAddCount(that,(res) => {
						let remainCount = CustomDict.ConstantVals.NonMember.CountOfContact - (res.data ? res.data : 0)
						if(that.isMember()){
							uni.makePhoneCall({
							  // 手机号 这里可以直接写号码如 12345 也可以写获取号码的字段如this.mobile
							  phoneNumber: item.contactPhone,
							  // 成功回调
							  success: (res) => {
							    console.log('调用拨打电话成功!')
								  Api.TrackApi.trackAdd(that, {
									userId: uni.getStorageSync('userId'),
									targetUserId: that.postDto.userId,
									recordId: that.postDto.id,
									extendInfo: CustomDict.TraceEventType.BtnAddContact.name,
									eventType: CustomDict.TraceEventType.BtnAddContact.value,
									trackCount: 1
								  }, (res) => {
											
								  })
							  },
							  // 失败回调
							  fail: (res) => {
							    console.log('调用失败!')
							  }
							});
						}else if(res.code == 200){
							if(res.data && res.data >= CustomDict.ConstantVals.NonMember.CountOfContact){
								that.showCustomTips({
								  title: '温馨提示',
								  content: CustomDict.ConstantVals.NonMember.TipOfContact,
								  confirmText: '注册会员',
								  confirmColor: '',
								  cancelText: '取消',
								  
								  success(res) {
								    if (res.confirm) {
								      uni.redirectTo({
								        url: '/MemberPage/member_index/member_index'
								      })
								    }else {
										
									}
								  }
								})
							}else{
								that.showCustomTips({
								  title: '温馨提示',
								  content: CustomDict.ConstantVals.NonMember.TipOfContactFun(res.data),
								  confirmText: '确定',
								  confirmColor: '',
								  cancelText: '取消',
								  
								  success(res) {
								    if (res.confirm) {
								      uni.makePhoneCall({
								        // 手机号 这里可以直接写号码如 12345 也可以写获取号码的字段如this.mobile
								        phoneNumber: item.contactPhone,
								        // 成功回调
								        success: (res) => {
								          console.log('调用拨打电话成功!')
										  Api.TrackApi.trackAdd(that, {
										    userId: uni.getStorageSync('userId'),
										    targetUserId: that.postDto.userId,
										    recordId: that.postDto.id,
										    extendInfo: CustomDict.TraceEventType.BtnAddContact.name,
										    eventType: CustomDict.TraceEventType.BtnAddContact.value,
										    trackCount: 1
										  }, (res) => {
										  			
										  })
								        },
								        // 失败回调
								        fail: (res) => {
								          console.log('调用失败!')
								        }
								      });
								    }else {
										
									}
								  }
								})
							}
						}
					})
					// uni.makePhoneCall({
					// 	// 手机号 这里可以直接写号码如 12345 也可以写获取号码的字段如this.mobile
					// 	phoneNumber: item.contactPhone,
					// 	// 成功回调
					// 	success: (res) => {
					// 		console.log('调用成功!')
					// 	},
					// 	// 失败回调
					// 	fail: (res) => {
					// 		console.log('调用失败!')
					// 	}
					// });
				}
			},
			addComment() {
				let that = this

				if (!(this.$store.state.sessionDto.postNumber > 0)) {
					console.log('用户发布的转铺数', this.$store.state.sessionDto.postNumber)

					this.showCustomModal({
						content: '只有在转店铺的店主才可直接联系求租人哦',
						cancelText: '我知道啦',
						confirmText: '去发布',
						success(res) {
							if (res.confirm) {
								console.log('点击了确定', res)
								uni.navigateTo({
									url: '/PostPage/post_add_sell/post_add_sell'
								})
								that.hideCustomModal()
							} else if (res.cancel) {
								console.log('用户取消注销');
							}
						}
					})

					// uni.showModal({
					// 	title: '',
					// 	content: '只有在转店铺的店主才可直接联系求租人',
					// 	cancelColor: '#666666',
					// 	showCancel: true,
					// 	cancelText: '我知道啦',
					// 	confirmColor: 'rgba(0, 0, 0, 0.85)',
					// 	confirmText: '去发布',
					// 	success: function (res) {
					// 		if (res.confirm) {
					// 			console.log('点击了确定', res)
					// 			uni.navigateTo({
					// 				url: '/pages/post_add_sell/post_add_sell'
					// 			})
					// 			// Api.MetricRecordApi.updateCollect(that, that.postDto.id, '0', (res) => {
					// 			//   if (res.code == 200) {
					// 			//     that.postDto.metricRecordDtoMap.collect = 0
					// 			//   }
					// 			// }, false)
					// 		} else if (res.cancel) {
					// 			console.log('用户取消注销');
					// 		}
					// 	}
					// })
					return
				}

				console.log('留言的内容', this.commentContent)
				if (!this.commentContent || this.commentContent.length < 5) {
					uni.showToast({
						title: '留言内容至少需要5个汉字哦～',
						icon: "none"
					})
					return
				}
				this.showAddComment = false
				Api.CustRequestSubscribeMessage(
					() => {

						Api.CommentApi.addNew(
							that,
							that.postDto.id,
							that.postDto.userId,
							that.commentContent,
							0,
							0,
							(res) => {
								if (res.code == 200) {
									check_utils.showCustToast('留言成功')
									that.commentContent = ''
								} else {
									check_utils.showCustToast(res.msg)
								}
							},
							true
						)

						// Api.CommentApi.addFromDetail(that, that.postDto, that.commentContent, 0, (res) => {
						// 	if (res.code == 200) {
						// 		check_utils.showCustToast('留言成功')
						// 		that.commentContent = ''
						// 		uni.navigateTo({
						// 			url: '/pages/post_list_my_message/post_list_my_message'
						// 		})
						// 	}
						// })
					},
					() => {

						Api.CommentApi.addNew(
							that,
							that.postDto.id,
							that.postDto.userId,
							that.commentContent,
							0,
							0,
							(res) => {
								if (res.code == 200) {
									check_utils.showCustToast('留言成功')
									that.commentContent = ''
								} else {
									check_utils.showCustToast(res.msg)
								}
							},
							true
						)
					}
				)
			},
			changeComment(commentContent) {
				console.log('留言内容', commentContent)
				this.commentContent = commentContent
			},
			confirmCollect() {
				let that = this
				uni.requestSubscribeMessage({
					tmplIds: ['SatyFF0dG2Asi3caTX8tVOT_GtnObUhOSEH945zpuOc'],
					success(collectRes) {
						console.log('允许订阅收藏通知提醒消息', collectRes)
						Api.MetricRecordApi.updateCollect(that, that.postDto.id, '1', (res) => {
							if (res.code == 200) {
								that.postDto.metricRecordDtoMap.collect = 1
							}
						}, false)
					},
					fail(err) {
						console.log('允许订阅收藏通知提醒消息返回异常', err)
						Api.MetricRecordApi.updateCollect(that, that.postDto.id, '1', (res) => {
							if (res.code == 200) {
								that.postDto.metricRecordDtoMap.collect = 1
							}
						}, false)
					}
				})

			},
			cancelCollect() {
				let that = this
				uni.showModal({
					title: '取消收藏',
					content: '是否取消收藏',
					cancelColor: '#FF6430',
					showCancel: true,
					cancelText: '取消',
					confirmColor: '#666666',
					confirmText: '确定',
					success: function(res) {
						if (res.confirm) {
							console.log('点击了确定', res)
							Api.MetricRecordApi.updateCollect(that, that.postDto.id, '0', (res) => {
								if (res.code == 200) {
									that.postDto.metricRecordDtoMap.collect = 0
								}
							}, false)
						} else if (res.cancel) {
							console.log('用户取消注销');
						}
					}
				})
			},
			initDetail(options) {
				console.log('初始化参数', options)
				let that = this
				if (options.detailJson && false) {

					this.postDto = JSON.parse(decodeURIComponent(options.detailJson))
					this.postDto.viewNumber = this.postDto.viewNumber ? (this.postDto.viewNumber + 1) : 1
					//添加足迹信息和更新浏览量
					Api.FootprintsApi.add(this.postDto.id, (footRes) => {}, false)
					Api.MetricRecordApi.updateViewNumber(that, {
						id: this.postDto.id,
						viewNumber: this.postDto.viewNumber
					}, (viewRes) => {}, false)
					// 导入发帖的账号信息到腾讯im中
					BackendApi.v05_post_importImAccount({
						userId: this.postDto.userId
					}, false)
				} else if (options.postId) {
					Api.PostApi.detail(options.postId, (res) => {
						if (res.code == 200) {
							res.data.viewNumber = res.data.viewNumber ? (res.data.viewNumber + 1) : 1
							that.postDto = res.data
							//添加足迹信息和更新浏览量
							if (!that.isMyPost(that.postDto)) {
								Api.FootprintsApi.add(options.postId, (footRes) => {}, false)
								Api.MetricRecordApi.updateViewNumber(that, {
									id: res.data.id,
									viewNumber: res.data.viewNumber
								}, (viewRes) => {}, false)
							}
							// 导入发帖的账号信息到腾讯im中
							BackendApi.v05_post_importImAccount({
								userId: res.data.userId
							}, false)
						}
					})
				} else {
					console.log('发帖详情参数错误', options)
				}
			},
			initMyPostList() {
				let that = this
				Api.MyApi.listOfMy(that, (res) => {
					that.myPostList = res.data.records
				})
			}
		},
		// 分享给微信好友
		onShareAppMessage(res) {

			return {
				title: '详情|' + PostUtils.getTitle(this.postDto),
				imageUrl: '/static/images/newlogo.png',
				path: '/PostPage/post_detail_buy/post_detail_buy?source=share&postId=' + this.postDto.id,
			}
		},
		// 分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '详情|' + PostUtils.getTitle(this.postDto),
				imageUrl: '/static/images/newlogo.png',
				path: '/PostPage/post_detail_buy/post_detail_buy?source=share&postId=' + this.postDto.id,
			}
		},
		watch: {},

		// 页面周期函数--监听页面加载
		onLoad(options) {
			let that = this
			if (options.source == 'share') {
				// 从分享而来
				Api.LoginApi.login(that, (res) => {
					that.fromMessagePage = options.fromMessagePage == 'true' ? true : false
					that.initDetail(options)
					that.initMyPostList()
				})
			} else {
				this.fromMessagePage = options.fromMessagePage == 'true' ? true : false
				this.initDetail(options)
				this.initMyPostList()
			}
			// this.fromMessagePage = options.fromMessagePage == 'true' ? true : false
			// this.initDetail(options)
			// this.initMyPostList()
		},
		// 页面周期函数--监听页面初次渲染完成
		onReady() {},
		// 页面周期函数--监听页面显示(not-nvue)
		onShow() {},
		// 页面周期函数--监听页面隐藏
		onHide() {},
		// 页面周期函数--监听页面卸载
		onUnload() {},
		// 页面处理函数--监听用户下拉动作
		// onPullDownRefresh() { uni.stopPullDownRefresh(); },
		// 页面处理函数--监听用户上拉触底
		// onReachBottom() {},
		// 页面处理函数--监听页面滚动(not-nvue)
		// onPageScroll(event) {},
		// 页面处理函数--用户点击右上角分享
		// onShareAppMessage(options) {},
	}
</script>

<style scoped lang="scss">
	@import url(../../static/css/base.css);

	page {
		height: 100vh;
	}

	.container {
		background: url(../../static/images/container-bg.png);
		width: 100%;
		height: 100vh;
	}

	.post-detail {
		// // margin: 0 32rpx 20rpx 32rpx;
		// margin: 24rpx 32rpx 0 32rpx;
		// border-radius: 16rpx;
		// background: #FFFFFF;
		// box-shadow: 0px 4px 6px 0px rgba(200, 186, 134, 0.36);
		// // padding: 24px;
		// padding-top: 40rpx;
		// padding-left: 48rpx;
		// padding-right: 32rpx;
		// position: relative;
		// padding-bottom: 32rpx;

		margin: 24rpx 32rpx 0 32rpx;
		border-radius: 16rpx;
		background: #FFFFFF;
		box-shadow: 0px 4px 6px 0px rgba(200, 186, 134, 0.36);
		padding-top: 40rpx;
		padding-left: 48rpx;
		padding-right: 32rpx;
		position: relative;
		padding-bottom: 32rpx;
		height: 532rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.save {
			// position: absolute;
			// right: 32rpx;
			// border-radius: 20px;
			// border-width: 1px;
			// padding: 5px 10px 5px 10px;
			// font-weight: bolder;
			// border: 1px solid #000000;
			// text-align: center;
			// margin-left: 40px;

			position: absolute;
			right: 32rpx;
			border-radius: 20px;
			border-width: 1px;
			/* padding: 5px 10px 5px 10px; */
			font-weight: 500;
			border: 1px solid #000000;
			text-align: center;
			margin-left: 40px;
			height: 48rpx;
			width: 128rpx;
			justify-content: center;
			font-size: 28rpx;
			top: 60rpx;

			.save-image {
				width: 24rpx;
				height: 24rpx;
				margin-left: 8rpx;
			}
		}

		.detail-title {
			font-size: 16px;
			font-weight: bolder;
		}

		.detail-times {
			margin-top: 24rpx;
			font-size: 14px;
			display: flex;
			font-size: 28rpx;
			font-weight: normal;
			color: #999999;
		}

		.info-wrap {
			display: flex;
			font-size: 14px;
			margin-top: 32rpx;
		}

		.info-title {
			font-size: 28rpx;
			color: #999999;
		}

		.info-content {
			margin-left: 12rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.85);
		}

	}

	.share {
		// margin: -50rpx 64rpx 0rpx 64rpx;
		// background: #F8D247;
		// padding: 86rpx 46rpx 50rpx 46rpx;
		// border-radius: 8px;
		// display: flex;

		background: #F8D247;
		// padding: 86rpx 46rpx 50rpx 46rpx;
		padding: 86rpx 30rpx 50rpx 30rpx;
		border-radius: 8px;
		display: flex;
		margin-left: 62rpx;
		margin-right: 62rpx;
		margin-top: -36rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.share-info {
			.share-info-title1 {
				font-weight: bolder;
				font-size: 16px;
			}

			.share-info-title2 {
				margin-top: 24rpx;
				font-size: 12px;
			}
		}

		.share-btn {
			// font-size: 14px;
			// border-radius: 50px;
			// border: 2px solid rgba(0, 0, 0, 0.85);
			// padding: 10px 16px 10px 16px;
			// font-weight: bolder;
			// border: solid;
			// text-align: center;
			// margin-left: 40px;

			font-size: 28rpx;
			border-radius: 50px;
			border: 2px solid rgba(0, 0, 0, 0.85);
			padding: 10px 16px 10px 16px;
			// font-weight: bolder;
			color: rgba(0, 0, 0, 0.85);
			border: solid;
			font-weight: 600;
			text-align: center;
			padding: 20rpx 32rpx;
			text-align: center;
			display: flex;
			align-items: center;
			border-radius: 200rpx;
			opacity: 1;

			box-sizing: border-box;
			border: 2px solid rgba(0, 0, 0, 0.85);
			height: 69rpx;
		}
	}

	.bottom-connection {
		position: absolute;
		display: flex;
		bottom: 0px;
		height: 72px;
		width: 100%;
		background: #FFFFFF;
		align-items: center;
		justify-content: space-evenly;

		.user-avater {
			width: 72rpx;
			height: 72rpx;
			border-radius: 72rpx;
		}

		.user-name {
			font-size: 14px;
			font-weight: bolder;
		}

		.gender {
			width: 8px;
			height: 8px;
		}

		.user-message {
			background: #F8D247;
			border: solid;
			border-radius: 4px;
			padding: 9px 16px 9px 16px;
		}

		.user-connect {
			background-color: #F87147;
			border: solid;
			border-radius: 4px;
			padding: 9px 16px 9px 16px;
		}
	}

	.footer {
		position: fixed;
		bottom: 0rpx;
		left: 0rpx;
		right: 0rpx;
		height: 144rpx;
		opacity: 1;

		background: #FFFFFF;

		box-shadow: 0px -1px 4px 0px rgba(0, 0, 0, 0.05);
		display: flex;
		align-items: center;
		justify-content: flex-start;

		.avatar {
			margin-left: 32rpx;
			width: 72rpx;
			height: 72rpx;
			border-radius: 50%;

			box-sizing: border-box;
			// border: 1px solid #F8D247;
		}

		.nickname-wrap {
			margin-left: 20rpx;
			font-size: 28rpx;
			font-weight: 600;
			color: #333333;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: flex-start;

			.nickname {}

			.nickname-label {
				border-radius: 200rpx;
				box-sizing: border-box;
				border: 2rpx solid #F87147;
				height: 32rpx;
				display: flex;
				flex-direction: row;
				justify-content: center;
				align-items: center;
				width: 128rpx;
				padding: 0 10rpx;

				.label-icon {
					display: block;
					width: 16.7rpx;
					height: 16rpx;
				}

				.label-title {
					font-size: 20rpx;
					font-weight: normal;
					color: #F87147;
					margin-left: 2.5rpx;
				}
			}
		}

		.comment {
			// padding: 18rpx 32rpx;
			// margin-right: 16rpx;
			// border-radius: 8rpx;
			// opacity: 1;

			// background: #F8D247;
			// font-size: 28rpx;
			// font-weight: 500;
			// color: rgba(0, 0, 0, 0.85);

			margin-right: 16rpx;
			border-radius: 8rpx;
			opacity: 1;
			background: #F8D247;
			font-size: 28rpx;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.85);
			height: 64rpx;
			display: flex;
			align-items: center;
			width: 176rpx;
			justify-content: center;
		}

		.contact {
			margin-right: 16rpx;
			border-radius: 8rpx;
			opacity: 1;
			background: #F87147;
			font-size: 28rpx;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.85);
			height: 64rpx;
			display: flex;
			align-items: center;
			width: 176rpx;
			justify-content: center;
		}
	}
</style>